package cn.koala.key.stock.controller;

import cn.koala.key.entity.EnterStock;
import cn.koala.key.stock.domain.dto.EnterStockDTO;
import cn.koala.key.stock.domain.dto.StockSearch;
import cn.koala.key.stock.service.EnterStockService;
import cn.ehi.authority.annotation.WebAuthentication;
import cn.seed.common.core.Result;
import cn.seed.common.core.ResultList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description:入库单
 * @author 32415
 * @time 2019/04/28
 **/
@RestController
@Api(value = "EnterStock",tags = "入库单")
public class EnterStockController {

    @Autowired
    private EnterStockService enterStockService;

    @ApiOperation(value = "入库查询")
    @GetMapping("/enter-stock")
    public Result<ResultList<EnterStock>> list(StockSearch enterStockSearch) {
        return enterStockService.list(enterStockSearch);
    }

    @ApiOperation(value = "新增/编辑入库单")
    @PostMapping("/enter-stock")
    @WebAuthentication(systemCode = "KoalaKey",moduleIds = "KOALAKEY_B_00013,KOALAKEY_B_00014,KOALAKEY_B_00019,KOALAKEY_B_00020")
    public Result insertOrUpdate(@RequestBody EnterStockDTO enterStockDTO) {
        return enterStockService.insertOrUpdate(enterStockDTO);
    }

    @ApiOperation(value = "作废/提交入库单")
    @PutMapping("/enter-stock")
    @WebAuthentication(systemCode = "KoalaKey",moduleIds = "KOALAKEY_B_00015,KOALAKEY_B_00017")
    public Result invalidOrSubmit(String orderNo,Integer status) {
        return enterStockService.invalidOrSubmit(orderNo,status);
    }

}
